package sala
{
	import flash.utils.Dictionary;
	/**
	 * ...
	 * @author Sun
	 */
	public class LanguageManager
	{
		private static var _language:String = "en"; 
		public static var xml:XML; 
		private static var xmlList: XMLList;
		
		// FONTS
		public static var REGULAR_FONT:String = "Cooper Black";
		public static var BOLD_FONT:String = "Cooper Black";
		public static var ITALIC_FONT:String = "Cooper Black";
		
		public static var dict:Dictionary = new Dictionary(); 
	
		public function LanguageManager() 
		{
			
		}
		
		// changing language 
		public static function setLanguage(lang:String): void
		{
			_language = lang;
			xmlList = dict[lang];
		}
		
		// adding xml to dictionary
		public static function setLanguageXML(xml: XML, lang:String = "") : void 
		{
			try 
			{
				LanguageManager.xml = xml;
				xmlList = LanguageManager.xml.elements("message");
				 	 
				dict[lang] = xmlList;
			}
			catch (err: Error)
			{
				trace("Xml is not good");
			}
		}
		
		static public function get language():String { return _language; }
		
		static public function set language(value:String):void 
		{
			_language = value;
		}
		
		public static function getText(id:String):String
		{
			for each (var transXML:XML in xmlList)
			{
				if (transXML.@id == id)
				{
					return transXML[0];
				}
			}
			return "";
		}
		
	}

}